<?php 
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header');
?> 
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>commoncheck.js"></script>
<body onload="menbercheck()">
<div class="txt_head_frame">
	<span class="txt_frame_title">修改管理员</span>
</div>
<div id="main_content">
<form name="myform" action="?m=admin&c=adminmanage&a=edit" method="post" id="myform">
<input type="hidden" name="info[userid]" value="<?php echo $userid?>"></input>
<input type="hidden" name="info[username]" value="<?php echo $username?>"></input>
<div class="txt_content_frame">
	<div class="txt_content_box">
		<div class="txt_content_left">
			<div class="txt_text_left">用户名:</div>
			<div class="txt_left_input"><?php echo $username?></div><br/><br/>
            <div class="txt_text_left">新密码:<span>[*]</span></div><input type="hidden" id="pwd" value="pwd"></input>
			<div class="txt_left_input"><input name="info[password]" type="password" class="txt" id="password"/></div><span id="validatepassword" class="validate"></span><br/><br/>
            <div class="txt_text_left">确定密码:<span>[*]</span></div>
			<div class="txt_left_input"><input name="info[pwdconfirm]" type="password" class="txt" id="pwdconfirm"/></div><span id="validatepwdconfirm" class="validate"></span><br/><br/>
            <div class="txt_text_left">email:<span>[*]</span></div>
			<div class="txt_left_input"><input name="info[email]" type="text" class="txt" id="email" value="<?php echo $email?>"/></div><span id="validateemail" class="validate"></span><br/><br/>
            <div class="txt_text_left">真实姓名:</div>
			<div class="txt_left_input"><input name="info[realname]" type="text" class="txt" id="realname" value="<?php echo $realname?>"/></div><span id="validaterealname" class="validate"></span><br/><br/>
            <div class="txt_text_left">用户角色:</div>
			<div class="txt_left_input">
            <select name="info[roleid]" class="select">
            <?php 
            	foreach($roles as $role) {            		
            ?>
			<option value="<?php echo $role['roleid']?>" <?php echo ($role['roleid'] == $roleid) ? 'selected' : ''?>><?php echo $role['rolename']?></option>
			<?php }?>
			</select>
			</div>           
		</div>
	</div>
</div>

<div class="txt_btn">
	<input name="dosubmit" type="submit" class="txt_btn_a" value=" 保存 " />
</div>
</form>
</div>
</body>
<script type="text/javascript">
<!--
//会员数据检测
function menbercheck(){
	$('#username').blur(function(){
		var validateUsername = $('#validateusername');
		if(isNotNull($(this).val())){
			if(is_username($(this).val())){				
				validateUsername.html('');
				var t = this;
				if(this.value != this.lastValue){
					if(this.timer){clearTimeout(this.timer);}
					validateUsername.html('');
					validateUsername.html('<img src="images/onLoad.gif" width=16 heigth=16>检测中');	
					this.timer = setTimeout(function(){
						$.ajax({
							type : "get",
							url : "",
							data : "m=admin&c=adminmanage&a=public_checkname_ajx&username="+t.value,
							success : function(data){
								if(data == "0"){									
									validateUsername.html('<img src="images/false.gif" width=16 heigth=16>用户名已存在');		
								}else {	
									validateUsername.html('<img src="images/true.gif" width=16 heigth=16>');		
								}
							}
						});
					},200);
					this.lastValue = this.value;
				}
			} else {
				validateUsername.html('<img src="images/false.gif" width=16 heigth=16>为2-20位字母数字或_');		
				
			}
		} else {
			validateUsername.html('<img src="images/false.gif" width=16 heigth=16>用户名不能为空');		
			return false;
		}
	});
	
	$('#password').blur(function(){
		var validatecPWD = $('#validatepassword');
		if(isNotNull($(this).val())){
			if(is_password($(this).val())){				
				validatecPWD.html('<img src="images/true.gif" width=16 heigth=16>');		
			}else {				
				validatecPWD.html('<img src="images/false.gif" width=16 heigth=16>密码为6-20位');	
			}
		} else {
			if($('#pwd').length>0){
				if($('#pwd').val() == 'pwd'){
					validatecPWD.html('<img src="images/true.gif" width=16 heigth=16>');
				}else{
					validatecPWD.html('<img src="images/false.gif" width=16 heigth=16>密码不能为空');
				}				
			}else{
				validatecPWD.html('<img src="images/false.gif" width=16 heigth=16>密码不能为空');
			}			
				
		}
	});
	
	$('#pwdconfirm').blur(function(){
		var validatecPWD2 = $('#validatepwdconfirm');
		if($(this).val() != $('#password').val()){
			validatecPWD2.html('<img src="images/false.gif" width=16 heigth=16>两次输入密码不同');	
		} else {
			validatecPWD2.html('<img src="images/true.gif" width=16 heigth=16>');		
		}
	});
	
	$('#email').blur(function(){
		var validateEmail = $('#validateemail');
		if(!is_email($(this).val())){
			validateEmail.html('<img src="images/false.gif" width=16 heigth=16>请输入正确的邮箱');	
		} else {
			validateEmail.html('<img src="images/true.gif" width=16 heigth=16>');		
		}
	});
	
	$('#realname').blur(function(){
		var validateName = $('#validaterealname');
		if(!isNotNull($(this).val())){
			validateName.html('<img src="images/false.gif" width=16 heigth=16>真实姓名不能为空');	
		} else {
			if(is_Name($(this).val())){
				validateName.html('<img src="images/true.gif" width=16 heigth=16>');		
			} else {
				validateName.html('<img src="images/false.gif" width=16 heigth=16>为4-15位中英组合');	
			}
		}
	});
}
//-->
</script>
</html>